package com.sdyeda.readiot.fx;


import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.fxml.FXMLLoader;
import java.io.IOException;

import com.sdyeda.readiot.ReadIotApplication;
import com.sdyeda.readiot.config.Setting;

public class MainWindow {
	
	private Scene scene;
	
	public MainWindow() {
		FXMLLoader loader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
		////解决无法使用 @Component 问题
		loader.setControllerFactory(ReadIotApplication.springContext::getBean);
		//loader.load();
		try {
			scene = new Scene(loader.load());
			Setting.Set(Setting.MAINWINDOW_CONTROLLER, loader.getController());
			
			ReadIotApplication.primaryStage.setScene(scene);
			ReadIotApplication.primaryStage.setTitle("尾矿库自动数据采集系统");
			ReadIotApplication.primaryStage.getIcons().add(new Image(MainWindow.class.getResourceAsStream("/logo.png")));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
